#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;


class Solution {
public:
    bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) {
        if(matrix.size()==0){
            return false;
        }
        int m = matrix.size();
        int n = matrix[0].size();

        int row = 0;
        int col = n-1;
        while (col>=0 && row<m)
        {
            if(matrix[row][col]==target){
                return true;
            }
            if(matrix[row][col]>target){
                col--;
            }else{
                row++;
            }
        }
        return false;
    }
};